package com.shouhe.mysap.config;

import com.baomidou.mybatisplus.core.injector.ISqlInjector;
import com.baomidou.mybatisplus.extension.injector.LogicSqlInjector;
import com.baomidou.mybatisplus.extension.plugins.OptimisticLockerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author 守鹤
 * @date 2020/5/31 21:43
 */
@Configuration
@MapperScan("com.shouhe.mysap.mapper")
public class MybatisConfig {

    // 注册乐观锁插件
    @Bean
    public OptimisticLockerInterceptor optimisticLockerInterceptor() {
        return new OptimisticLockerInterceptor();
    }


    // 分页插件
    @Bean public PaginationInterceptor paginationInterceptor() { return new PaginationInterceptor(); }

    // 逻辑删除
    @Bean public ISqlInjector sqlInjector() { return new LogicSqlInjector(); }

}
